package org.aceor.mddal.gateway.datatype.cal;

/**
 * Created by lxue on 16/4/16.
 */
public abstract class AbstractCalculator implements Calculator {
    @Override
    public Object add(Object value1, Object value2) {
        return (value1 != null && value2 != null) ? doAdd(value1, value2) : null;
    }

    public abstract Object doAdd(Object value1, Object value2);

    @Override
    public Object sub(Object value1, Object value2) {
        return (value1 != null && value2 != null) ? doSub(value1, value2) : null;
    }

    public abstract Object doSub(Object value1, Object value2);

    @Override
    public Object multiply(Object value1, Object value2) {
        return (value1 != null && value2 != null) ? doMultiply(value1, value2) : null;
    }

    public abstract Object doMultiply(Object value1, Object value2);

    @Override
    public Object divide(Object value1, Object value2) {
        return (value1 != null && value2 != null) ? doDivide(value1, value2) : null;
    }
    public abstract Object doDivide(Object value1, Object value2);
}
